#include "test.h"

//创建文件写入读取和删除

int main()
{
    umask(000);
    int n = mkfifo(FNAME,0666);
    if(n == -1)
    {
        printf("%s%d:%s\n","mkfifo error! ",errno,strerror(errno));
        exit(EOF);
    }

    int fd = open(FNAME,O_WRONLY);
    if(fd == -1)
    {
        printf("%s%d:%s\n","open write error! ",errno,strerror(errno));
        exit(EOF);
    }

    while(true)
    {
        char str[_size] = {0};
        char *s = fgets(str,sizeof(str)-1,stdin);
        (void*)s;
        str[strlen(str) - 1] = 0;
        if(strcmp(str,"quit") == 0) break;
        write(fd,str,sizeof(str));
    }

    close(fd);

    unlink(FNAME);
    
    return 0;
}